package com.yehongyu.mytools.fileio;

import java.io.IOException;
import java.io.RandomAccessFile;

public class AccessFile {

	public static void main(String[] args) {
		try {
			RandomAccessFile in = new RandomAccessFile("D:/dev/otherwork/codeutil/logdir/mytools.log", "rw");
			//随机读取文件
			int tRead = 0;
			while (tRead != -1) {
				tRead = in.read();
				System.out.print((char)tRead);
			}
			
			//寻找到末尾写入
			in.seek(in.length());
			in.write("叶宏宇".getBytes());
            in.write(13);
            in.write(10); //Minim add for 回车换行；
			
			//关闭随机读取
			in.close();
		} catch (IOException exception) {
			System.out.print(exception.toString());
		}
	}
}
